<extend name="./Common/View/EasyUI/form.html"/>
<block name="form">
    <div class="row">
        <div class="span12">
            <form method="post" id="pageForm" class="form-horizontal" action="Sys/User/password">
                <input name="id" id="id" value="{$vo.id}" type="hidden">
                <table class="table table-bordered table-striped">
                    <tbody>
                    <tr>
                        <th colspan="2">修改密码</th>
                    </tr> <tr>
                        <td class="revise-left" width="15%"><span class="text-error">*</span>原始密码:</td>
                        <td>
                            <input name="oldp" id="oldp" type="password" placeholder="请输入原始密码"
                                   class="easyui-validatebox"
                                   data-options="required:true,validType:'length[1,20]'">
                        </td>
                    </tr>
                    <tr>
                        <td class="revise-left" width="15%"><span class="text-error">*</span>新密码:</td>
                        <td>
                            <input name="password" id="password" type="password" placeholder="请输入新密码"
                                   class="easyui-validatebox"
                                   data-options="required:true,validType:'length[1,20]'">
                        </td>
                    </tr>
                    <tr>
                        <td class="revise-left" width="15%"><span class="text-error">*</span>确认密码:</td>
                        <td>
                            <input name="repass" id="repass" type="password" value="{$vo.title}" placeholder="再次输入的密码要一致"
                                   class="easyui-validatebox"
                                   data-options="required:true,validType:'same[\'password\']'">
                        </td>
                    </tr>
                    <tr>
                        <td class="revise-left" width="15%"></td>
                        <td>
                            <input type="submit" class="btn-primary" value="确定">
                            <input type="reset" class="btn-default" value="取消">
                        </td>
                    </tr>

                    </tbody>
                </table>

            </form>
        </div>
    </div>
</block>

<block name="script">
    <script src="__PUBLIC__/js/jquery.md5.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#pageForm').on('submit',function () {
                sumitPassowrd();
                return false;
            });
        });

        //参考submitTabForm方法
        function sumitPassowrd() {
            var $form = $('#pageForm');
            //表单验证
            if(!$form.form('validate')) {
                top.layout.message('请检查您输入的数据', '错误提示!');
                return false;
            }
            var data = {id:$('#id').val()};
            data.oldp = $.md5($('#oldp').val() + app.md5_salt);
            data.password = $.md5($('#password').val() + app.md5_salt);
            $.post(app.api + $form.attr('action'),data,function (res) {
                if(res.error == 0){
                    top.layout.message(res.message, '操作成功!');
                    if(res.url){
                        top.layout.openTab(res.url, res.message);
                    }
                    //top.layout.mainTab.tabs('close', '修改密码'); //关闭当前窗口
                }else{
                    top.layout.message(res.message, '操作失败!');
                }
            });
        }
    </script>
</block>